<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">studentId</label>
        <div class="layui-input-block">
            <input type="text" name="studentId" id="studentId" lay-verify="required" lay-reqtext="studentId不能为空" placeholder="请输入studentId" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">studentName</label>
        <div class="layui-input-block">
            <input type="text" name="studentName" id="studentName" lay-verify="required" lay-reqtext="studentName不能为空" placeholder="请输入studentName" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">studentGender</label>
        <div class="layui-input-block">
            <input type="text" name="studentGender" id="studentGender" lay-verify="required" lay-reqtext="studentGender不能为空" placeholder="请输入studentGender" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">studentBirth</label>
        <div class="layui-input-block">
            <input type="text" name="studentBirth" id="studentBirth" lay-verify="required" lay-reqtext="studentBirth不能为空" placeholder="请输入studentBirth" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">studentTel</label>
        <div class="layui-input-block">
            <input type="text" name="studentTel" id="studentTel" lay-verify="required" lay-reqtext="studentTel不能为空" placeholder="请输入studentTel" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">studentWechat</label>
        <div class="layui-input-block">
            <input type="text" name="studentWechat" id="studentWechat" lay-verify="required" lay-reqtext="studentWechat不能为空" placeholder="请输入studentWechat" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">studentQq</label>
        <div class="layui-input-block">
            <input type="text" name="studentQq" id="studentQq" lay-verify="required" lay-reqtext="studentQq不能为空" placeholder="请输入studentQq" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">studentUniversity</label>
        <div class="layui-input-block">
            <input type="text" name="studentUniversity" id="studentUniversity" lay-verify="required" lay-reqtext="studentUniversity不能为空" placeholder="请输入studentUniversity" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">studentMajor</label>
        <div class="layui-input-block">
            <input type="text" name="studentMajor" id="studentMajor" lay-verify="required" lay-reqtext="studentMajor不能为空" placeholder="请输入studentMajor" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">studentGraduationTiem</label>
        <div class="layui-input-block">
            <input type="text" name="studentGraduationTiem" id="studentGraduationTiem" lay-verify="required" lay-reqtext="studentGraduationTiem不能为空" placeholder="请输入studentGraduationTiem" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">studentTechnology</label>
        <div class="layui-input-block">
            <input type="text" name="studentTechnology" id="studentTechnology" lay-verify="required" lay-reqtext="studentTechnology不能为空" placeholder="请输入studentTechnology" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">studentIsAccommodation</label>
        <div class="layui-input-block">
            <input type="text" name="studentIsAccommodation" id="studentIsAccommodation" lay-verify="required" lay-reqtext="studentIsAccommodation不能为空" placeholder="请输入studentIsAccommodation" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">accommodationNo</label>
        <div class="layui-input-block">
            <input type="text" name="accommodationNo" id="accommodationNo" lay-verify="required" lay-reqtext="accommodationNo不能为空" placeholder="请输入accommodationNo" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">admissionDate</label>
        <div class="layui-input-block">
            <input type="text" name="admissionDate" id="admissionDate" lay-verify="required" lay-reqtext="admissionDate不能为空" placeholder="请输入admissionDate" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">providedComputer</label>
        <div class="layui-input-block">
            <input type="text" name="providedComputer" id="providedComputer" lay-verify="required" lay-reqtext="providedComputer不能为空" placeholder="请输入providedComputer" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">consultantId</label>
        <div class="layui-input-block">
            <input type="text" name="consultantId" id="consultantId" lay-verify="required" lay-reqtext="consultantId不能为空" placeholder="请输入consultantId" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">sourceDescription</label>
        <div class="layui-input-block">
            <input type="text" name="sourceDescription" id="sourceDescription" lay-verify="required" lay-reqtext="sourceDescription不能为空" placeholder="请输入sourceDescription" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">studyDirection</label>
        <div class="layui-input-block">
            <input type="text" name="studyDirection" id="studyDirection" lay-verify="required" lay-reqtext="studyDirection不能为空" placeholder="请输入studyDirection" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">linkMan</label>
        <div class="layui-input-block">
            <input type="text" name="linkMan" id="linkMan" lay-verify="required" lay-reqtext="linkMan不能为空" placeholder="请输入linkMan" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">studyMotivation</label>
        <div class="layui-input-block">
            <input type="text" name="studyMotivation" id="studyMotivation" lay-verify="required" lay-reqtext="studyMotivation不能为空" placeholder="请输入studyMotivation" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">costSource</label>
        <div class="layui-input-block">
            <input type="text" name="costSource" id="costSource" lay-verify="required" lay-reqtext="costSource不能为空" placeholder="请输入costSource" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">idcard</label>
        <div class="layui-input-block">
            <input type="text" name="idcard" id="idcard" lay-verify="required" lay-reqtext="idcard不能为空" placeholder="请输入idcard" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">classId</label>
        <div class="layui-input-block">
            <input type="text" name="classId" id="classId" lay-verify="required" lay-reqtext="classId不能为空" placeholder="请输入classId" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">remark</label>
        <div class="layui-input-block">
            <input type="text" name="remark" id="remark" lay-verify="required" lay-reqtext="remark不能为空" placeholder="请输入remark" value="" class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
</div>
<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
<script>

    let studentId = undefined;
    //  获取传递参数  bankId
    let href = location.href; 
    let hrefs = href.split("?");
    if(hrefs!=undefined && hrefs.length == 2){
        let params = hrefs[1].split("&") 
        if(params!=undefined && params.length > 0){
            for(var x = 0;x < params.length ;x ++){
                let ps = params[x].split("="); 
                if(ps[0]=='studentId'){
                    studentId = ps[1];
                }
            }
        }
    }

    // 加载数据,回显到表单中
    $.ajax({
        async:false,
        type:"get",
        url:"/studentInfo/get?studentId="+studentId,
        success:function(res){
        	            	$("#studentId").val(res.studentId);
                        	$("#studentName").val(res.studentName);
                        	$("#studentGender").val(res.studentGender);
                        	$("#studentBirth").val(res.studentBirth);
                        	$("#studentTel").val(res.studentTel);
                        	$("#studentWechat").val(res.studentWechat);
                        	$("#studentQq").val(res.studentQq);
                        	$("#studentUniversity").val(res.studentUniversity);
                        	$("#studentMajor").val(res.studentMajor);
                        	$("#studentGraduationTiem").val(res.studentGraduationTiem);
                        	$("#studentTechnology").val(res.studentTechnology);
                        	$("#studentIsAccommodation").val(res.studentIsAccommodation);
                        	$("#accommodationNo").val(res.accommodationNo);
                        	$("#admissionDate").val(res.admissionDate);
                        	$("#providedComputer").val(res.providedComputer);
                        	$("#consultantId").val(res.consultantId);
                        	$("#sourceDescription").val(res.sourceDescription);
                        	$("#studyDirection").val(res.studyDirection);
                        	$("#linkMan").val(res.linkMan);
                        	$("#studyMotivation").val(res.studyMotivation);
                        	$("#costSource").val(res.costSource);
                        	$("#idcard").val(res.idcard);
                        	$("#classId").val(res.classId);
                        	$("#remark").val(res.remark);
                    }
    });



    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            let obj = data.field;
            obj.studentId = studentId;
            $.ajax({
                type:"POST",
                url:"/studentInfo/update",
                data:obj, 
                success:function(res){
                    if(res.code==200){
                        var index = layer.alert("编辑成功", {
                            title: '提示'
                        }, function () {
                            // 关闭弹出层
                            layer.close(index);
                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(iframeIndex);
                        });
                    }else if(res.code==501){
                        var index = layer.alert("重复");
                    }else{
                        var index = layer.alert("编辑失败");
                    }
                }
            });
            return false;
        });

    });
</script>
</body>
</html>